package com.yoyo.web.action;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;

import com.yoyo.biz.UserBiz;
import com.yoyo.entity.Pagination;
import com.yoyo.entity.User;

@Controller
public class AdminAction {
	@Resource
	private UserBiz service;
	private List<User> users;
	private User user;

	private String message ;
	/*分页*/
	private int pageNo = 1;
	private String parentID  ;
	private Pagination pagination ;
	
	public User getUser() {
		return user;
	}
	public void setUser(User user) {
		this.user = user;
	}
	
	public List<User> getUsers() {
		return users;
	}

	public void setUsers(List<User> users) {
		this.users = users;
	}
	
	public String getMessage() {
		return message;
	}
	public void setMessage(String message) {
		this.message = message;
	}

	public int getPageNo() {
		return pageNo;
	}

	public void setPageNo(int pageNo) {
		this.pageNo = pageNo;
	}

	public String getParentID() {
		return parentID;
	}

	public void setParentID(String parentID) {
		this.parentID = parentID;
	}

	public Pagination getPagination() {
		return pagination;
	}

	public void setPagination(Pagination pagination) {
		this.pagination = pagination;
	}

	public void setService(UserBiz service) {
		this.service = service;
	}
	
	
	/*------------------------------------------------*/
	
	public String userList(){
		List<User> list = service.findAll();
    	pagination = new Pagination(pageNo, 2,list.size(), 5,"admin_userList.do","pagenum");
    	users = pagination.getPageDate(list);
		return "userList";
	}
	
	public String delectUser(){
		
		return "delectUser";
	}
	
	public String editUserUI(){
    	user = service.find(user.getId());    	
    	return "editUI" ;
    }
	
	public String editUser(){
		service.update(this.user);   
        this.message="用户修改成功";   
        return "success";
	}
}
